#pragma once

#include "KuaDu/Renderer/OrthographicCamera.h"
#include "KuaDu/Core/TimeStep.h"
#include "KuaDu/Events/ApplicationEvent.h"
#include "KuaDu/Events/MouseEvent.h"

namespace KD {

	class OrthographicCameraController
	{
	public:
		OrthographicCameraController(float aspectRatio, bool rotation = false);

		void OnUpdate(TimeStep ts);

		void OnEvent(Event& e);

		void OnResize(float width, float height);

		OrthographicCamera& GetCamera() { return m_Camera; }
		const OrthographicCamera& GetCamera() const { return m_Camera; }

		float GetZoomLevel() { return m_ZoomLevel; }
		void SetZoomLevel(float level)
		{
			m_ZoomLevel = level;
			RecalculateView();
		}
	private:
		void RecalculateView();

		bool OnMouseScrolled(MouseScrolledEvent& e);
		bool OnWindowResize(WindowResizeEvent& e);
	private:
		float m_AspectRatio;
		float m_ZoomLevel = 0.1f;
		bool m_Rotation;
		glm::vec3 m_CameraPosition = glm::vec3(0.0f);
		float m_CameraRotation = 0.0f;
		float m_CameraTranslationSpeek = 5.0f, m_CameraRotationSpeek = 180.0f;
		OrthographicCamera m_Camera;
	};
}